package com.jugheadzhou.mqtt.producer.gateway;

import org.springframework.integration.annotation.MessagingGateway;
import org.springframework.integration.mqtt.support.MqttHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;

/**
 * mqtt发送网关
 *
 * @author jugheadzhou
 */
@Component
@MessagingGateway(defaultRequestChannel = "mqttOutboundChannel")
public interface MqttGatewayComponent {

    /**
     * 发送消息至指定topic
     * <p color = red>此方法不推荐使用！！发送消息时请先调用GzipUtil内的数据压缩方法发送字节数组</p>
     *
     * @param payload 消息内容
     * @param topic   topic
     */
    void sendToMqtt(String payload, @Header(MqttHeaders.TOPIC) String topic);

    /**
     * 发送消息至指定topic 能指定qos
     *
     * @param payload 消息内容
     * @param topic   topic
     * @param qos     值为 0 1 2
     */
    void sendToMqtt(@Header(MqttHeaders.TOPIC) String topic, @Header(MqttHeaders.QOS) int qos, String payload);
}
